package com.fyzk.activity.zhifu;

import com.fyzk.activity.lottery.basketball.JCLQFragmentActivityI;
import com.fyzk.activity.lottery.basketball.JCLQPayActivity;
import com.fyzk.activity.lottery.jc.football.guoguan.JC_GuoGuanDialog;
import com.fyzk.activity.lottery.jc.football.guoguan.JC_GuoGuanInfor;
import com.fyzk.adapter.JCLQHGPayAdapter;
import com.fyzk.model.JCLQMatchData;
import com.fyzk.model.JCLQMatchData.SPInfo;
import com.fyzk.utils.IntentParamUtils;
import com.fyzk.utils.LotteryIDUtils;

import java.util.List;

/** 竞彩篮球胜负投注类 */
public class JCLQHGPayActivity extends JCLQPayActivity {

	@Override
	protected void setAdapter() {
		// TODO Auto-generated method stub
		isDanguan = getIntent().getBooleanExtra(IntentParamUtils.TYPE_GUOGUAN,
				false);
		adapter = new JCLQHGPayAdapter(this, isDanguan,
                jcInfors, handler, this);
		listView.setAdapter(adapter);

	}
	
	@Override
	protected int getMaxGuoGuan() {
		// TODO Auto-generated method stub
		boolean hasSFC = false;
		for (int j = 0; j < JCLQFragmentActivityI.matchs.size(); j++) {
			JCLQMatchData info = JCLQFragmentActivityI.matchs.get(j);
			if(info.getSfcNum()>0){
				hasSFC = true;
			}
		}
		return hasSFC?4:8;
	}

	@Override
	protected String getContent() {
		// TODO Auto-generated method stub
		List<String> chuans = JC_GuoGuanInfor.getChuanIds(
				JC_GuoGuanDialog.result, isDanguan);
		String content = "";
		for (int i = 0; i < chuans.size(); i++) {
			content += lotteryId + "" + wanFa + chuans.get(i) + "-";// 301012001-
			String n = "";
			for (int j = 0; j < JCLQFragmentActivityI.matchs.size(); j++) {
				JCLQMatchData info = JCLQFragmentActivityI.matchs.get(j);
				// * 竞彩混合注码格式
				// 300512001-20140330302*3004(2)|20140330302*3001(1,3)|20140330307
				// * *3001(0)^ 与非混合的区别是，赛事编号后面多了一个玩法字段。
				StringBuffer danChang = new StringBuffer();
				if (info.clickNum != 0) {
					danChang.append(info.getMatchNum());
					danChang.append("*");
					StringBuffer sb_sf = new StringBuffer();
					{
						JCLQMatchData.SPInfo sf_s = info.plInfos.get(0);
						SPInfo sf_f = info.plInfos.get(1);

						if (sf_s.isSel) {
							sb_sf.append(sf_s.codeValue);
							sb_sf.append(",");
						}
						if (sf_f.isSel) {
							sb_sf.append(sf_f.codeValue);
							sb_sf.append(",");
						}
					}
					if (sb_sf.length() > 0) {
						danChang.append(LotteryIDUtils.JLSF_LOTTERY_ID_INT);
						danChang.append("(");
						danChang.append(sb_sf.substring(0, sb_sf.length() - 1));
						danChang.append(")");
						danChang.append("|");
						danChang.append(info.getMatchNum());
						danChang.append("*");
					}

					StringBuffer sb_rsf = new StringBuffer();
					{
						JCLQMatchData.SPInfo rsf_s = info.plInfos.get(2);
						SPInfo rsf_f = info.plInfos.get(3);
						if (rsf_s.isSel) {
							sb_rsf.append(rsf_s.codeValue);
							sb_rsf.append(",");
						}
						if (rsf_f.isSel) {
							sb_rsf.append(rsf_f.codeValue);
							sb_rsf.append(",");
						}
					}
					if (sb_rsf.length() > 0) {
						danChang.append(LotteryIDUtils.JLRSF_LOTTERY_ID_INT);
						danChang.append("(");
						danChang.append(sb_rsf.substring(0, sb_rsf.length() - 1));
						danChang.append(")");
						danChang.append("|");
						danChang.append(info.getMatchNum());
						danChang.append("*");
					}
					StringBuffer sb_dxf = new StringBuffer();
					{
						JCLQMatchData.SPInfo dxf_d = info.plInfos.get(4);
						JCLQMatchData.SPInfo dxf_x = info.plInfos.get(5);
						if (dxf_d.isSel) {
							sb_dxf.append(dxf_d.codeValue);
							sb_dxf.append(",");
						}
						if (dxf_x.isSel) {
							sb_dxf.append(dxf_x.codeValue);
							sb_dxf.append(",");
						}
					}
					if (sb_dxf.length() > 0) {
						danChang.append(LotteryIDUtils.JLDXF_LOTTERY_ID_INT);
						danChang.append("(");
						danChang.append(sb_dxf.substring(0, sb_dxf.length() - 1));
						danChang.append(")");
						danChang.append("|");
						danChang.append(info.getMatchNum());
						danChang.append("*");
					}
					StringBuffer sb_sfc = new StringBuffer();
					{
						for (int x = 6; x < (info.plInfos.size()); x++) {
							SPInfo sp = info.plInfos.get(x);
							if (sp.isSel) {
								sb_sfc.append(sp.codeValue);
								sb_sfc.append(",");
							}
						}
					}
					if (sb_sfc.length() > 0) {
						danChang.append(LotteryIDUtils.JLSFC_LOTTERY_ID_INT);
						danChang.append("(");
						danChang.append(sb_sfc.substring(0, sb_sfc.length() - 1));
						danChang.append(")");
						danChang.append("|");
						danChang.append(info.getMatchNum());
						danChang.append("*");
					}
				}
				if (danChang.length() > 0) {
					n += danChang.substring(0,
							danChang.length() - (info.getMatchNum().length() + 2))
							+ "|";
				}
			}
			if (!n.equals("")) {
				n = n.substring(0, n.length() - 1);
				n += "^";
			}
			content += n + "!";
		}
		if (!content.equals("")) {
			content = content.substring(0, content.length() - 1);
		}
		return content;
	}

}
